package com.hq.controller;

import com.hq.bean.Users;
import com.hq.service.CompanyService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
public class CompanyController {

    @Resource
    private CompanyService companyService;

    @RequestMapping("login.do")
    public String login(Users users, HttpSession session){
        Map u=companyService.login(users);
        if(u!=null){
            session.setAttribute("user",u);
            return "main";
        }else {
            return "redirect:index.jsp";
        }
    }


    @RequestMapping("list1.do")
    public String list1(Model model){
        List list=companyService.list();
        model.addAttribute("list",list);
        return "list1";
    }

    @RequestMapping("toadd.do")
    public String toadd(){
        return "toadd";
    }

    @RequestMapping("manageList.do")
    @ResponseBody
    public Object manageList(String stime,Integer cid){
        List list=companyService.manageList(stime,cid);
        return list;
    }
}
